/**
 * 选择  特别总账标识
 * http://jira.ecsphere.net:9080/browse/XYL-1423
 * 1、特别总账标识：账户类型（客户-D、供应商-K)

(说明：客户代码选择了值，账户类型就传D、供应商代码选择了值，账户类型就传K）
 * */
import {useEffect, useState} from 'react';
import {CellInput} from '../components-v2';
import * as CommonDataSource from '../../../common-data-source';
export interface SelectSpecialAccountFlagProps {
	// 账户类型
	accountType: 'K' | 'D' | '',
	detailMode?: boolean,
	shop: string,

}
export function SelectSpecialAccountFlag(props: CellInput.ICellInputProps<string> & SelectSpecialAccountFlagProps) {
	const {accountType = "", value, disabled, onChange, detailMode = false, shop = ''} = props;

	const [options, setOptions] = useState<Array<{name: string, value: string}>>([]);

	// useEffect(function () {
	// 	CommonDataSource.others.querySpecialFlagOptions(shop, accountType)
	// 		.then(setOptions);
	// }, [shop, accountType]);

	if(detailMode) {
		const name = options.find((item) => item.value === value)?.name || '';
		return <span>{name}</span>
	}

	return (
			<CellInput.Selector style={{minWidth: '200px'}} valueInLabel dataSource={options} showSearch disabled={disabled} value={value} onChange={onChange}/>
	)
}
